package com.imooc.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author Zhou
 * @create 2020-11-15 16:11
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

    /*
    * swagger2的配置文件，这里可以配置swagger2的一些基本的内容，比如扫描的包等等
    * */
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.imooc.controller"))
                .paths(PathSelectors.any()).build();
    }
    /*
     * 构建api文档的基本信息
     * */
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("使用swagger2构建短视频后端api接口文档")
                .contact(new Contact("zwd", "http://www/imooc.com", "imooc@168.com"))
                .description("欢迎访问短视频接口文档，这里是描述信息")
                .version("1.0").build();
    }
}
